<%@page import="monster.comm.util.SpringApplicationContextFactory"%>
<%@page import="monster.flight.admin.manager.service.admin.Flight_infoService"%>
<%@page import="monster.flight.comm.util.FlightFactory"%>
<%@page import="monster.comm.util.DateUtil"%>
<%@page import="monster.flight.comm.entity.vo.FlightBay"%>
<%@page import="sun.jdbc.rowset.CachedRowSet"%>
<%@page import="monster.flight.comm.entity.vo.Flight_info"%>
<%@page import="monster.comm.database.DBManager"%>
<%@page import="monster.comm.util.SysConstant"%>
<%@page import="monster.comm.util.UserService"%>
<%@page import="monster.comm.util.Tool"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String type=Tool.getRequest("type",request);//必传参数
String now_time=Tool.getRequest("now_time",request);//必传参数
String list="";
if(type.equals(""))type="1";
UserService user = (UserService) session.getAttribute(SysConstant.SESSION_NAME);//获得session里面的登陆信息
if(1==2){
	out.println("{\"id\":-100,\"name\":\"没有登录\"}");
	return;
}else{
	try{
		DBManager db = new DBManager();
		String sql="";
		if(type.equals("1")){//随机
			sql="SELECT RAN_SN SN,STAFF_NAME,'随机' T_NAME,RAN_START_DATETIME ST,RAN_END_DATETIME ET,FLIGHT_NO RE FROM STAFF_RAN_PLAN where RAN_START_DATETIME<='"+now_time+"' and RAN_END_DATETIME>='"+now_time+"'  ORDER BY RAN_START_DATETIME DESC";
		}else if(type.equals("2")){//驻站
			sql="SELECT STATION_SN SN,STAFF_NAME,'驻站' T_NAME,STATION_START_DATETIME ST,STATION_END_DATETIME ET,STATION_PLACE RE FROM STAFF_STATION_PLAN where STATION_START_DATETIME<='"+now_time+"' and STATION_END_DATETIME>='"+now_time+"' ORDER BY STATION_START_DATETIME DESC";
		}else if(type.equals("3")){//休假
			sql="SELECT RAN_SN SN,STAFF_NAME,'休假' T_NAME,HOLIDAY_START_DATETIME ST,HOLIDAY_END_DATETIME ET,HOLIDAY_CLASS RE FROM STAFF_HOLIDAY_PLAN where HOLIDAY_START_DATETIME<='"+now_time+"' and HOLIDAY_END_DATETIME>='"+now_time+"' ORDER BY HOLIDAY_START_DATETIME DESC";
		}					
		CachedRowSet cr = db.getRowSet(sql);
		StringBuilder sb = new StringBuilder(200);
		int i=1;
		while(cr.next()){
			String sn = Tool.getRsValue(cr,"sn");
			String staff_name = Tool.getRsValue(cr,"staff_name");
			String t_name = Tool.getRsValue(cr,"t_name");
			String st = Tool.getRsValue(cr,"st");
			String et = Tool.getRsValue(cr,"et");
			String re = Tool.getRsValue(cr,"re");
			if(type.equals("3")){
				if(re.equals("0"))re="公休";
				if(re.equals("1"))re="婚假";
				if(re.equals("2"))re="丧假";
				if(re.equals("3"))re="事假";
				if(re.equals("4"))re="其它休假";
			}
			sb.append("{\"staff_name\":\"").append(staff_name).append("\",")
			.append("\"sn\":\"").append(sn).append("\",")
			.append("\"t_name\":\"").append(st).append("\",")
			.append("\"st\":\"").append(st).append("\",")
			.append("\"et\":\"").append(et).append("\",")
			.append("\"re\":\"").append(re).append("\"")
			.append("}");
			if(i++<cr.size()){
				sb.append(",");
			}
		}		
		 list="{\"id\":100,\"list\":["+sb.toString()+"]}";
	}catch(Exception e){
		 e.printStackTrace();
		 list="{\"id\":-200,\"name\":\"程序异常\"}";
	}
	
	out.println(list);

}
%>
